﻿using EMall.OrderService.Orders;
using EMall.Query;
using Microsoft.AspNetCore.Mvc;

namespace EMall.OrderService.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class OrderController : ControllerBase, IOrderAppService
    {
        private readonly IOrderAppService _orderAppService;
        public OrderController(IOrderAppService orderAppService)
        {
            _orderAppService = orderAppService;
        }
        [HttpPost]
        public async Task CreateAsync(CreateOrderDto input)
        {
            await _orderAppService.CreateAsync(input);
        }
        [HttpPut]
        public async Task UpdateAsync(UpdateOrderDto input)
        {
            await _orderAppService.UpdateAsync(input);
        }
        [HttpPut]
        public async Task ShipAsync(ShipOrderDto input)
        {
            await _orderAppService.ShipAsync(input);
        }
        [HttpPut]
        public async Task ReceiveAsync(ReceiveOrderDto input)
        {
            await _orderAppService.ReceiveAsync(input);
        }
        [HttpPut]
        public async Task CancelAsync(CancelOrderDto input)
        {
            await _orderAppService.CancelAsync(input);
        }
        [HttpPut]
        public async Task RefundAsync(RefundOrderDto input)
        {
            await _orderAppService.RefundAsync(input);
        }
        [HttpGet]
        public async Task<OrderDto> GetAsync(int id)
        {
            return await _orderAppService.GetAsync(id);
        }
        [HttpGet]
        public async Task<IPagedList<OrderListDto>> GetPagedListAsync([FromQuery] GetOrderListPagingAndSortingQueryDto input)
        {
            return await _orderAppService.GetPagedListAsync(input);
        }

    }
}
